package com.jianbo.proxy.util;

import java.util.HashMap;
import java.util.Map;

public class ThreadDataUtil {
    
    private static ThreadLocal<Map<String, Object>> data =new ThreadLocal<>();

    public static void put(String key, String value) {
        Map<String, Object> map = data.get();
        if(map == null) {
            data.set(new HashMap<>());
            map = data.get();
        }
        map.put(key, value);
    }

    public static void clear() {
        data.remove();
    }

    @SuppressWarnings("all")
    public static <T> T get(String key) {
        return (T)data.get().get(key);
    }


}
